{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "90578ccf",
   "metadata": {},
   "source": [
    "### week13_字典实践/集合及集合实践"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f69fbe0",
   "metadata": {},
   "source": [
    "- > 学习人：杨茜\n",
    "- > 记录时间：2021-11-22\n",
    "- >记录内容：week13 python课程笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "acc37991",
   "metadata": {},
   "source": [
    "### 本周\n",
    "#### 1.字典的实践\n",
    "#### 2.集合的操作\n",
    "#### 3.集合的运算\n",
    "#### 4.集合的一般方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8c4230f2",
   "metadata": {},
   "source": [
    "### 字典的实践\n",
    "* 数据源：高德API 逆地理编码\n",
    "> 1.处理字典的一般操作流程\n",
    "> 2.处理列表的一般操作流程"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "642e5c2c",
   "metadata": {},
   "source": [
    "> 字典的一般操作方法\n",
    ">> A.观察key的所有值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a3a85eba",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e0f2b669",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院['status']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f82804d",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院['info']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7421d4f5",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院['infocode']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ada000e",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode = 广州南方学院['regeocode']\n",
    "广州南方学院_regeocode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "242234b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode['roadinters']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81a84bb1",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode['formatted_address']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e710a2b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode[]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fcf6d63",
   "metadata": {},
   "source": [
    "- > 1.aois:用户搜索过的内容\n",
    "- > 2.pois:根据用户搜索过的内容给出相关/周边/相似内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17fffaa3",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode['aois']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "536e9326",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode['pois']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9bb9a377",
   "metadata": {},
   "source": [
    " > 2.列表的一般操作 \n",
    " >> A.查看列表的长度.len()   \n",
    " >> B.查看列表的第一个元素list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "103c38c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第一步\n",
    "len(广州南方学院_regeocode_pois)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4bef982",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第二步\n",
    "广州南方学院_regeocode_pois[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "084ae6bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode_pois_id = []\n",
    "广州南方学院_regeocode_pois_id = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b6213d44",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode_pois_name.append(i['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "567c3350",
   "metadata": {},
   "outputs": [],
   "source": [
    "广州南方学院_regeocode_pois_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a9bc56f",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in 广州南方学院_regeocode_pois:\n",
    "#      print(i['direction'])\n",
    "    if i['direction'] == '北' and '教学楼' in i['name']：\n",
    "       print(i['name'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f6b88b38",
   "metadata": {},
   "source": [
    "### 集合sets的用法\n",
    "> 1.\n",
    "> 2. \n",
    "> 3.集合的一般方法\n",
    ">> A.pop()      \n",
    ">> B.remove()     \n",
    ">> C.clear()      \n",
    ">> D.add()      \n",
    ">> E....       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b4bd9514",
   "metadata": {},
   "outputs": [],
   "source": [
    "set_1 = set([1,2,5,6,7,2,3,2,4,4])   # list to set 列表和集合之间的转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40942289",
   "metadata": {},
   "outputs": [],
   "source": [
    "print (set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f97249f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "help(set.1._intersection)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abcabfd2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实验一\n",
    "set_1.intersection(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97f7c62a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实验二\n",
    "set_1 & set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "65b14f14",
   "metadata": {},
   "outputs": [],
   "source": [
    "> 2.并集\n",
    ">> A.union()\n",
    ">> B."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c339d945",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(set_1)\n",
    "print(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03de5981",
   "metadata": {},
   "outputs": [],
   "source": [
    "help(set_1.union)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "404987a8",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(set_1.union(set_2)) # 自动去除重复项"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e7fbe315",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(set_1|set_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "769b5a26",
   "metadata": {},
   "source": [
    "> 3.差集\n",
    ">> A. differences()   \n",
    ">> B. 逻辑运算符：-"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "00b0f66e",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(set_1)\n",
    "print(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "faac9066",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 差集运算有先后区分 \n",
    "# 实验一：differences（）\n",
    "set_1.differences(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "885f7a5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "set_2.differences(set_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "66ac9518",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实验二：逻辑运算符：-\n",
    "set_1 - set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fcf63029",
   "metadata": {},
   "outputs": [],
   "source": [
    "set_2 - set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e44688a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "> 4.对称差集\n",
    ">> A. \n",
    ">> B. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24d672e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "> 2.删除\n",
    ">> 1. pop()随即删除成员\n",
    ">> 2. remove()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
